************** this stata script replicates the results presented in tables S8-S11 in supplementary materials *************

*interaction model A 
clear all
import delimited "Interaction_model_A.txt" 


global dependent ego_distance_t
global engogenous c.av_fr_distance_t#i.Running_Activity_fraction_indicator
global instruments c.fr_rain_7_t#i.Running_Activity_fraction_indicator 
global control_variables ego_distance_t_1 ego_tmax_t ego_prcp_t ego_connectivity_t av_fr_connectivity_t av_fr_age av_fr_age av_fr_weight portion_of_friends_that_male portion_of_friends_US portion_of_friends_UK portion_of_friends_JP portion_of_friends_CA portion_of_friends_wristdevice portion_of_friends_application1 portion_of_friends_application2 

xi: ivreg2 $dependent ( $engogenous = $instruments )  $control_variables i.ego_num i.day_num , first small cluster(community_id)

*interaction model B
clear all
import delimited "Interaction_model_B.txt" 

global dependent ego_distance_t
global engogenous c.av_fr_distance_t_fe#i.category_indicator 
global instruments c.fr_rain_7_t_fe#i.category_indicator    c.fr_tmax_2_t_fe#i.category_indicator 
global control_variables ego_distance_t_1 ego_tmax_t ego_prcp_t ego_connectivity_t av_fr_connectivity_t av_fr_age av_fr_age av_fr_weight portion_of_friends_that_male portion_of_friends_US portion_of_friends_UK portion_of_friends_JP portion_of_friends_CA portion_of_friends_wristdevice portion_of_friends_application1 portion_of_friends_application2  

xi: ivreg2 $dependent ( $engogenous = $instruments )  $control_variables i.ego_num i.day_num , first small cluster(community_id)


*interaction model C
clear all
import delimited "Interaction_model_C.txt" 

global dependent ego_distance_t
global engogenous c.av_fr_distance_t_fe#i.consistency_interaction_category
global instruments c.fr_rain_7_t_fe#i.consistency_interaction_category    c.fr_tmax_2_t_fe#i.consistency_interaction_category 
global control_variables ego_distance_t_1 ego_tmax_t ego_prcp_t ego_connectivity_t av_fr_connectivity_t av_fr_age av_fr_age av_fr_weight portion_of_friends_that_male portion_of_friends_US portion_of_friends_UK portion_of_friends_JP portion_of_friends_CA portion_of_friends_wristdevice portion_of_friends_application1 portion_of_friends_application2  

xi: ivreg2 $dependent ( $engogenous = $instruments )  $control_variables i.ego_num i.day_num , first small cluster(community_id)

*interaction model D
clear all
import delimited "Interaction_model_D.txt" 

global dependent ego_distance_t
global engogenous c.av_fr_distance_t#i.gender_interaction_category 
global instruments  c.fr_rain_7_t#i.gender_interaction_category
global control_variables ego_distance_t_1 ego_tmax_t ego_prcp_t ego_connectivity_t av_fr_connectivity_t av_fr_age av_fr_age av_fr_weight portion_of_friends_that_male portion_of_friends_US portion_of_friends_UK portion_of_friends_JP portion_of_friends_CA portion_of_friends_wristdevice portion_of_friends_application1 portion_of_friends_application2  

xi: ivreg2 $dependent ( $engogenous = $instruments )  $control_variables i.ego_num i.day_num , first first small cluster(community_id)